﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace CoreModule.Converters
{
    /// <summary>
    /// 
    /// </summary>
    public class NumericScalerConverter : IValueConverter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
           if (value == null || parameter==null)
            {
                return 0.0d;
            }
            try
            {
                var dValue = (double)value;
                var dParameter = double.Parse(parameter.ToString());
                return dValue * dParameter;
            } catch (Exception )
            {
                return 0.0d;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}